<template>
  <z-modal
    title="流程图"
    width="80%"
    :fullscreen.sync="fullscreen"
    :footer="null"
    :bodyStyle="{'padding':'0px'}"
    v-bind="modalOption"
    @ok="handleOk"
    @cancel="handleCancel"
  >
  <Bpmn :flow="flow" @ok="saveDiagram" />
  </z-modal>
</template>

<script>
import ModalMixins from '@/mixins/ModalMixins'
import Bpmn from '@/components/bpmn/bpmn'
import { putAction } from '@/services/manage'
import { CURY_TYPE } from '@/store/mutation-types'
export default {
  name: 'BpmnFlowModal',
  mixins: [ModalMixins],
  components: { Bpmn },
  data() {
    return {
      flow: {},
      fullscreen: true,
      url: {
        save: '/camunda/flow/edit'
      }
    }
  },
  methods: {
    show(data) {
      this.visible = true
      this.flow = data
    },
    saveDiagram(data) {
      putAction(this.url.save, {
        ...this.flow,
        xml: data.xml,
        crudType: CURY_TYPE.UPDATE
      }).then(res => {
        if (res.success) {
          this.$message.success('保存成功')
          this.$emit('ok')
        }
      })
    }
  }
}
</script>
